package com.leetcode.partition4;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/2/12 19:54
 */
public class LC307区域和检索_数组可修改 {

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        int n = Integer.parseInt(ss[0]), m = Integer.parseInt(ss[1]);
        int[] nums = new int[n];
        ss = reader.readLine().split(" ");
        for (int i = 0; i < n; i++) nums[i] = Integer.parseInt(ss[i]);
        NumArray numArray = new NumArray(nums);
        while (m-- > 0) {
            ss = reader.readLine().split(" ");
            int a = Integer.parseInt(ss[1]), b = Integer.parseInt(ss[2]);
            if (ss[0].charAt(0) == 'S') {
                writer.write(numArray.sumRange(a, b) + "\n");
            } else {
                numArray.update(a, b);
            }
        }
        writer.flush();
    }

    private static class NumArray {

        private final int N = 30010;
        private int[] a = new int[N], c = new int[N];
        private int n = 0;

        public NumArray(int[] nums) {
            n = nums.length;
            for (int i = 1; i <= n; i++) {
                a[i] = nums[i - 1];
                add(i, nums[i - 1]);
            }
        }

        public void update(int index, int val) {
            index++;
            add(index, val - a[index]);
            a[index] = val;
        }

        public int sumRange(int left, int right) {
            left++;
            right++;
            return ask(right) - ask(left - 1);
        }

        private int ask(int x) {
            int res = 0;
            for (int i = x; i != 0; i -= lowbit(i)) res += c[i];
            return res;
        }

        private void add(int x, int k) {
            for (int i = x; i <= n; i += lowbit(i)) c[i] += k;
        }

        private int lowbit(int x) {
            return x & -x;
        }
    }
}
